from django.db import models

# Create your models here.


class Novel(models.Model):
    title = models.CharField(max_length=256)
    author = models.CharField(max_length=128)
    category = models.CharField(max_length=128)
    summary = models.TextField()
    source_url = models.CharField(max_length=2048)
    created_at = models.DateTimeField(auto_now_add=True)


class Chapter(models.Model):
    novel = models.ForeignKey(Novel, on_delete=models.CASCADE)
    title = models.CharField(max_length=1024)
    parent = models.ForeignKey(
        'self', null=True, blank=True, on_delete=models.SET_NULL)
    content = models.TextField()
    sort_no = models.IntegerField(default=0)
    source_url = models.CharField(max_length=2048)
    created_at = models.DateTimeField(auto_now_add=True)
